﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Fjaspx.DB;//请先添加引用

namespace Fjaspx.Sys.Dal
{
  public  class Page
    {
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        /// <param name="TableName">Name of the table.</param>
        /// <param name="OrderFld">The order FLD.</param>
        /// <param name="PageSize">Size of the page.</param>
        /// <param name="PageIndex">Index of the page.</param>
        /// <param name="strWhere">The STR where.</param>
        /// <returns></returns>
        public DataSet GetList(string TableName,string OrderFld, int PageSize, int PageIndex, string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = TableName;
            parameters[1].Value = OrderFld;
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage", parameters, "ds");
        }
        /// <summary>
        /// Gets the list.
        /// </summary>
        /// <param name="SQL">The SQL.</param>
        /// <returns></returns>
        public DataSet GetList(string SQL)
        {
            return DbHelperSQL.Query(SQL.ToString());
        }
    }
}
